#ifndef SOCKET_H
#define SOCKET_H

#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdlib.h>
#include <string>

class Socket
{
 public:

  Socket();
  Socket(int port);
  virtual ~Socket();

  void writeLine(const char *s);
  std::string readLine(int max = 256);
  
  int readMsg(void *buf, int toRead);
  int sendMsg(const void *buf, int toSend);
  
  int send4(unsigned long data);
  int read4(long* data);

  int closeSock();

 protected:

  struct sockaddr_in _addr;
  int _sock;
  int _port;

};

#endif
